import 'package:flutter/material.dart';
import 'package:flutter_snail/ui/style/snail_text_style.dart';

/// 推荐活动
class RecommendActivityCard extends StatelessWidget {
  const RecommendActivityCard(
      {Key? key, required this.list, required this.controller})
      : super(key: key);

  final List<int> list;
  final ScrollController controller;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 170,
      child: ListView.separated(
        scrollDirection: Axis.horizontal,
        physics: const NeverScrollableScrollPhysics()
            .applyTo(const ClampingScrollPhysics()),
        controller: controller,
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
        itemBuilder: (_, index) => _ActivityCard(index: index),
        separatorBuilder: (BuildContext context, int index) =>
            const SizedBox(width: 20),
        itemCount: list.length,
      ),
    );
  }
}

class RecommendActivity extends StatefulWidget {
  const RecommendActivity({Key? key}) : super(key: key);

  @override
  State<RecommendActivity> createState() => _RecommendActivityState();
}

class _RecommendActivityState extends State<RecommendActivity> {
  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }
}

class _ActivityCard extends StatelessWidget {
  const _ActivityCard({Key? key, required this.index}) : super(key: key);

  final int index;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        _buildImage(),
        const SizedBox(height: 10),
        _buildText(),
      ],
    );
  }

  _buildImage() {
    var item = Expanded(
      child: Container(
        width: 80,
        height: 80,
        decoration: BoxDecoration(
            shape: BoxShape.circle, color: Colors.purple[(index + 1) * 100]),
      ),
    );
    return item;
  }

  _buildText() {
    return Text('$index$index$index', style: SnailTextStyle.greyCD_14);
  }
}
